#include "Scene.h"

class ParticleSys:public Scene
{
public:
	ParticleSys(SceneEvnArgs evn):Scene(evn){}

	bool frameRenderingQueued(const FrameEvent& evt)
	{
		// spin the head around and make it float up and down
		mPivot->yaw(Degree(evt.timeSinceLastFrame * 30));
		return Scene::frameRenderingQueued(evt);
	}

	virtual void createScene(void)
	{
		// dim orange ambient and two bright orange lights to match the skybox
		mSceneMgr->setAmbientLight(ColourValue(0.3, 0.2, 0));
		Light* light = mSceneMgr->createLight();
		light->setPosition(2000, 1000, -1000);
		light->setDiffuseColour(1, 0.5, 0);
		light = mSceneMgr->createLight();
        light->setPosition(-2000, 1000, 1000);
		light->setDiffuseColour(1, 0.5, 0);

		setupParticles();   // setup particles
	}

	void setupParticles()
	{
		ParticleSystem::setDefaultNonVisibleUpdateTimeout(5);  // set nonvisible timeout

		ParticleSystem* ps;
		ps = mSceneMgr->createParticleSystem("Smoke", "Examples/Smoke");
		Entity* ent;
		ent = mSceneMgr->createEntity("Head", "ogrehead.mesh");

        // create shared pivot node for spinning the fountains
        mPivot = mSceneMgr->getRootSceneNode()->createChildSceneNode();

		// create a child node and attach an ogre head and some smoke to it
		SceneNode* Effect = mPivot->createChildSceneNode(Ogre::Vector3(100, 0, 0));
		//Effect->attachObject(ent);
        Effect->attachObject(ps);

	}

	SceneNode* mPivot;
};